package com.abc.controller;

import com.abc.bean.Bunk;
import com.abc.bean.Department;
import com.abc.service.BunkService;
import com.abc.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: bc
 * @Date: 2024-11-17 12:44
 * @Description:
 */
@RestController()
@RequestMapping("/department")
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;

    @RequestMapping("/selectDepartment")
    public List<Department> selectDepartment(String departmentName) {
        return departmentService.selectDepartment(departmentName);
    }
    @RequestMapping("/selectAllDepartment")
    public List<Department> selectAllDepartment() {
        return departmentService.selectAllDepartment();
    }
    @RequestMapping("/addDepartment")
    public String addDepartment(Department department) {
        return departmentService.addDepartment(department) > 0 ? "添加成功" : "添加失败";
    }
    @RequestMapping("/deleteDepartment")
    public String deleteDepartment(String id) {
        return departmentService.deleteDepartment(id) > 0 ? "删除成功" : "删除失败";
    }
    @RequestMapping("/updateDepartmentById")
    public String updateDepartmentById(Department department) {
        return departmentService.updateDepartmentById(department) > 0 ? "修改成功" : "修改失败";
    }
    @RequestMapping("/selectOneDepartmentById")
    public Department selectOneDepartmentById(String id) {
        return departmentService.selectOneDepartmentById(id);
    }
}
